import React, { Component } from "react";

export default class child extends Component {
  constructor() {
    super();
  }
    static getDerivedStateFromProps() {
      console.log("getDerivedStateFromProps");
    }
    
  componentWillMount() {
    console.log("componentWillMount");
  }
  componentDidMount() {
    console.log("componentDidMount");
  }
  componentDidUpdate() {
    console.log("componentDidUpdate");
  }
  componentWillReceiveProps() {
    console.log("componentWillReceiveProps");
  }

  getSnapshotBeforeUpdate(a, b) {
    console.log(a, b, "getSnapShowBeforeUpdate");
    return true;
  }

  shouldComponentUpdate() {
    console.log("shouldComponentUpdate");
    return true;
  }
  state = {
    num: 1,
  };
  handleClick = () => {
    this.setState({
      num: this.state.num + 1,
    });
  };
  render() {
    console.log(this.props, "render");
    return (
      <>
        <h1>类组件</h1>
        <div>child</div>
        <div>{this.state.num}</div>
        <button onClick={this.handleClick}>num++</button>
      </>
    );
  }
}
